<!--bind-alipay-->
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <link href="../../libs/mui.min.css" rel="stylesheet"/>
    <link href="../../css/main.css" rel="stylesheet"/>
    <link rel="stylesheet" href="../../css/mine-distribution.css"/>
</head>

<body class="band-ali">
<div class="head">
    <img class="mui-action-back" src="../../images/all-left.png" alt="">
    <p>支付宝绑定</p>
</div>
<div class="content bindali" ids="">
    <p>
        <span>支付宝账号</span><input type="text" id="alipayId"/>
    </p>
    <p>
        <span>真实姓名</span><input type="text" id="real-name"/>
    </p>

    <button id="saveAlipay">保存</button>
</div>
<script src="../../js/jquery-3.1.1.min.js"></script>
<script src="../../libs/mui.min.js"></script>
<script src="../../js/url.js"></script>
<script>
    //获取支付宝绑定信息
    $.ajax({
        type: "get",
        url: ur + "rest/alipayController/get",
        async: true,
        headers: {
            'X-Token': localStorage.token
        },
        dataType: 'json',
        success: function (res) {
            if (res.meta.code == 'S002') {
                if(res.data!==null){
                    $('#alipayId').val(res.data.email);
                    $('#real-name').val(res.data.realName);
                    $('.bindali').attr('ids', res.data.id);
                }
            } else {
                mui.toast('获取支付宝信息失败');
            }
        }
    });
    //新增或修改支付宝绑定信息
    $('#saveAlipay').on('tap', function () {
//				plus.nativeUI.showWaiting();
        $.ajax({
            type: "post",
            url: ur + "rest/alipayController/save",
            async: true,
            headers: {
                'X-Token': localStorage.token
            },
            dataType: 'json',
            data: {
                email: $('#alipayId').val(),
                id: $('.bindali').attr('ids'),
                realName: $('#real-name').val()
            },
            success: function (res) {
//						plus.nativeUI.closeWaiting();
                if (res.meta.code == 'S002') {
                    mui.toast('保存成功！');
                } else {
                    mui.toast('保存失败，请重试');
                }
            }
        });
    })
</script>
</body>

</html>